using System.Windows.Forms;
using igp.net.DataModel;

namespace igp.net
{
	/// <summary>
	/// Represents the options window.
	/// </summary>
	public partial class FormOptions
	{
        /// <summary>
        /// Default constructor.
        /// </summary>
		public FormOptions()
		{
			InitializeComponent();
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			Close();
		}

		private void FormOptions_Load(object sender, System.EventArgs e)
		{
            propertyGrid1.SelectedObject = igpSettings.Singleton;
		}

        private void FormOptions_FormClosed(object sender, FormClosedEventArgs e)
        {
            ApplyOptions();
        }

        private static void ApplyOptions()
        {
            IgpProject.Singleton.ReinitializeGraphics();
            FormMain.Singleton.ClearView();
            FormMain.Singleton.Render();
            FormMain.Singleton.PaintView();
        }

        private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
        {
            ApplyOptions();
        }
	}
}
